using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter09
{
	/// <summary>
	/// Example18: The Exploding Rocket
	/// A rocket is fired vertically upward. At the instant 
	/// it reaches an altitude of 1000 m and a speed of 300 m/s, 
	/// it explodes into three fragments having equal mass. 
	/// One fragment continues to move upward with a speed 
	/// of 450 m/s following the explosion. The second fragment 
	/// has a speed of 240 m/s and is moving east right after 
	/// the explosion. What is the velocity of the third 
	/// fragment right after the explosion?
	/// v_f = -240 i + 450 j  m/s
	/// </summary>
	public class Example18
	{
		public Example18()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Mass M = new L.Mass();
			M.kg = 10.0;
			L.Mass m = new L.Mass();
			m.kg = M.kg/3.0;
			L.Velocity[] v = new L.Velocity[4];
			v[0] = new L.Velocity();
			v[0].Y = 300.0;
			v[1] = new L.Velocity();
			v[1].Y = 450.0;
			v[2] = new L.Velocity();
			v[2].X = 240.0;
			v[3] = new L.Velocity();
			v[3].XVariableQ = true;
			v[3].YVariableQ = true;
			L.Momentum pi = new L.Momentum(M,v[0]);
			L.Momentum[] pf = new L.Momentum[3];
			pf[0] = new L.Momentum(m,v[1]);
			pf[1] = new L.Momentum(m,v[2]);
			pf[2] = new L.Momentum(m,v[3]);
			L.FundamentalLaw.MomentumConservation(pi,pf);
			result+=Convert.ToString(pf[2].X/m.kg)+"\r\n";
			result+=Convert.ToString(pf[2].Y/m.kg)+"\r\n";
		}
	}
}
